package cs8;

public class Worker {
	
	public String name;
	public int age;
	public double salary;
	public Address address;
	
	public Address getAddress(){
		return address;
	}
	public void setAddress(Address address){
		this.address=address;
	}
	public Worker(){
	}
	public Worker(String name,int age,double salary,Address address){
		this.name=name;
		this.age=age;
		this.salary=salary;
		this.address=address;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public double getSalary() {
		return salary;
	}
	
	public void setSalary(double salary) {
		this.salary = salary;
	}
	@Override
	public String toString() {
		return "Worker [name=" + name + ", age=" + age + ", salary=" + salary + ", address=" + address + "]";
	}

	@Override
	public boolean equals(Object obj){
		Worker w = null;
		if(obj instanceof Worker){
			w = (Worker)obj;
		}
		if(w.getName().equals(this.name)&&w.getAge()==this.age&&w.getAddress().equals(this.address)&&w.getSalary()==this.salary){
			return true;
		}
		return false;
	}
	@Override
	public int hashCode(){
		int hashCode = (int) (this.name.hashCode()+this.age+this.salary+this.age+this.address.hashCode());
		return hashCode;
	}
	
}
